Telegram Group & Telegram Channel
Note #59: Релиз кандидат (RC1) для Go 1.14

Из наиболее значимого в go 1.14 внесли изменения в спецификацию языка, а именно, теперь разрешается встраивать интерфейсы с пересекающимися наборами методов.

Возвращаясь к реальной жизни давайте разберем пример типичного интерфейса:
package user

type Database interface {
GetUser(userID uint64) (model.User, error)
}

И допустим у меня есть несколько других пакетов, из которые я тоже хочу доставать информацию о пользователе, поэтому нам необходимо встроить интерфейс user.Database в hardware.Database и тоже самое для wallet.Database:
package hardware

type Database interface {
user.Database
SaveDevice(usertID uint64, device model.Device) error
}

package wallet

type Database interface {
user.Database
ReadWallet(userID uint64) (model.Wallet, error)
}

Ну и классика жанра, прилетает задача где нужно создать интерфейс shopping.Database который должен в себе содержать методы hardware.Database и wallet.Database:
package shopping

type Database interface {
wallet.Database
hardware.Database
Buy(userID uint64, deviceID uint64) error
}
И в go версии меньше чем go 1.14 мы получим ошибку:
Duplicate method GetUser(userID uint64) (model.User, error)
Если запустить go1.14rc1 run main.go то все будет ок 🎉

P.S. эта проблема была еще озвучена Алоном Донованом в 2013 году!!! [1]

Links:
[1] spec: allow embedding overlapping interfaces https://github.com/golang/go/issues/6977
[2] Proposal https://github.com/golang/proposal/blob/master/design/6977-overlapping-interfaces.md



tg-me.com/golang_for_two/85
Create:
Last Update:

Note #59: Релиз кандидат (RC1) для Go 1.14

Из наиболее значимого в go 1.14 внесли изменения в спецификацию языка, а именно, теперь разрешается встраивать интерфейсы с пересекающимися наборами методов.

Возвращаясь к реальной жизни давайте разберем пример типичного интерфейса:

package user

type Database interface {
GetUser(userID uint64) (model.User, error)
}

И допустим у меня есть несколько других пакетов, из которые я тоже хочу доставать информацию о пользователе, поэтому нам необходимо встроить интерфейс user.Database в hardware.Database и тоже самое для wallet.Database:
package hardware

type Database interface {
user.Database
SaveDevice(usertID uint64, device model.Device) error
}

package wallet

type Database interface {
user.Database
ReadWallet(userID uint64) (model.Wallet, error)
}

Ну и классика жанра, прилетает задача где нужно создать интерфейс shopping.Database который должен в себе содержать методы hardware.Database и wallet.Database:
package shopping

type Database interface {
wallet.Database
hardware.Database
Buy(userID uint64, deviceID uint64) error
}
И в go версии меньше чем go 1.14 мы получим ошибку:
Duplicate method GetUser(userID uint64) (model.User, error)
Если запустить go1.14rc1 run main.go то все будет ок 🎉

P.S. эта проблема была еще озвучена Алоном Донованом в 2013 году!!! [1]

Links:
[1] spec: allow embedding overlapping interfaces https://github.com/golang/go/issues/6977
[2] Proposal https://github.com/golang/proposal/blob/master/design/6977-overlapping-interfaces.md

BY 🇺🇦 Go for two :)


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/golang_for_two/85

View MORE
Open in Telegram


🇺🇦 Go на двоих Telegram | DID YOU KNOW?

Date: |

Telegram auto-delete message, expiring invites, and more

elegram is updating its messaging app with options for auto-deleting messages, expiring invite links, and new unlimited groups, the company shared in a blog post. Much like Signal, Telegram received a burst of new users in the confusion over WhatsApp’s privacy policy and now the company is adopting features that were already part of its competitors’ apps, features which offer more security and privacy. Auto-deleting messages were already possible in Telegram’s encrypted Secret Chats, but this new update for iOS and Android adds the option to make messages disappear in any kind of chat. Auto-delete can be enabled inside of chats, and set to delete either 24 hours or seven days after messages are sent. Auto-delete won’t remove every message though; if a message was sent before the feature was turned on, it’ll stick around. Telegram’s competitors have had similar features: WhatsApp introduced a feature in 2020 and Signal has had disappearing messages since at least 2016.

NEWS: Telegram supports Facetime video calls NOW!

Secure video calling is in high demand. As an alternative to Zoom, many people are using end-to-end encrypted apps such as WhatsApp, FaceTime or Signal to speak to friends and family face-to-face since coronavirus lockdowns started to take place across the world. There’s another option—secure communications app Telegram just added video calling to its feature set, available on both iOS and Android. The new feature is also super secure—like Signal and WhatsApp and unlike Zoom (yet), video calls will be end-to-end encrypted.

🇺🇦 Go на двоих from sg


Telegram 🇺🇦 Go for two :)
FROM USA